{% load i18n adminmedia fb_tags fb_versions %}

{% for file in page.object_list %}
    <tr class="{% cycle 'row1' 'row2' %}{% if file.filetype == "Folder" %} fb_folder{% endif %}">
        
        <!-- FILESELECT FOR FILEBROWSEFIELD -->
        {% if query.pop == "1" and results_var.select_total %}
            <td class="fb_icon">
                {% selectable file.filetype query.type %}
                {% if selectable %}
                    <button class="button fb_selectlink" onclick="FileSubmit('{{ file.url_save }}', '{{ file.url_thumbnail }}', '{{ file.filetype }}');">{% trans "Select" %}</button>
                {% else %}
                    &nbsp;
                {% endif %}
            </td>
        {% endif %}
        
        <!-- FILESELECT FOR RTE/TINYMCE -->
        {% if query.pop == "2" and results_var.select_total %}
            <td class="fb_icon">
                {% selectable file.filetype query.type %}
                {% if selectable %}
                    <button class="button fb_selectlink" onclick="FileBrowserDialogue.fileSubmit('{{ file.url_save|escapejs }}');">{% trans "Select" %}</button>
                {% else %}
                    &nbsp;
                {% endif %}
            </td>
        {% endif %}
        
        <!-- FILESELECT FOR CKEDITOR (FORMER "FCKEDITOR") -->
        {% if query.pop == "3" and results_var.select_total %}
            <td class="fb_icon">
                {% selectable file.filetype query.type %}
                {% if selectable %}
                    <button class="button fb_selectlink" onclick="OpenFile(ProtectPath('{{ file.url_save|escapejs }}'));return false;">{% trans "Select" %}</button>
                {% else %}
                    &nbsp;
                {% endif %}
            </td>
        {% endif %}
        
        <!-- FILEICON -->
        <td>
            {% comment %}<img src="{{ settings_var.URL_FILEBROWSER_MEDIA }}img/filebrowser_type_{{ file.filetype|lower }}.gif" />{% endcomment %}
            <span class="fb_type {{ file.filetype|lower }}">{{ file.filetype }}</span>
        </td>
        
        <!-- THUMBNAIL -->
        <td class="fb_thumbnail">
            {% if file.filetype == "Image" %}
                <a href="{{ file.url_full }}" class="fb_viewlink"><img src="{% version file.path settings_var.ADMIN_THUMBNAIL %}" title="{% trans 'View Image' %}" /></a>
            {% endif %}
        </td>
        
        <!-- FILENAME/DIMENSIONS -->
        {% if file.filetype == "Folder" %}
            <td><a href="{% url fb_browse %}{% query_string "" "q,dir,p" %}&amp;dir={{ file.path_relative_directory|urlencode }}"><strong>{{ file.filename }}</strong></a></td>
        {% else %}
            <td>
                <b><a href="{{ file.url_full }}">{{ file.filename }}</a></b>
                {% if file.dimensions %}
                    <br /><span class="tiny">{{ file.dimensions.0 }} x {{ file.dimensions.1 }} px</span><br clear="all" />
                {% endif %}
                {% comment %}
                {% if file.filetype == "Image" %}
                    <a class="preview fb_showpreview" href="javascript://" title="{% trans 'Preview' %}">{% trans 'Preview' %}</a>
                    <div class="fb_preview_container">
                        <a href="{{ file.url_full }}" class="fb_view_image external" target="_blank"><span>{% trans 'View Image' %}</span><img src="{% version file.path settings_var.PREVIEW_VERSION %}" title="{% trans 'View Image' %}" class="fb_preview" /></a>
                    </div>
                {% endif %}
                {% endcomment %}
                {% if results_var.images_total and settings_var.ADMIN_VERSIONS and file.filetype == "Image" %}
                    <a class="internal fb_showversions" href="{% url fb_versions %}{% query_string "" "p" %}&amp;filename={{ file.filename }}" title="{% trans 'Versions' %}">{% trans 'Versions' %}</a>
                {% endif %}
            </td>
        {% endif %}
        
        <!-- FOLDER -->
        {% if q %}<td>{{ file.folder }}</td>{% endif %}
        
        <!-- SIZE -->
        <td>{{ file.filesize|filesizeformat }}</td>
        
        <!-- DATE -->
        <td>{{ file.datetime|date:"N j, Y" }}</td>
        
        <!-- ACTIONS -->
        <td>
            <div class="pulldown-actions-container">
                <a href="javascript://" class="pulldown-actions-handler">&nbsp;</a>
                <ul class="pulldown-actions">
                    <li><a href="{% url fb_rename %}{% query_string %}&amp;filename={{ file.filename }}" title="{% trans 'Rename' %}">{% trans 'Rename' %}</a></li>
                    {% ifnotequal file.filetype 'Folder' %}
                        <li><a href="{% url fb_delete %}{% query_string %}&amp;filename={{ file.filename }}&amp;filetype={{ file.filetype }}" onclick="return confirm('{% trans "Are you sure you want to delete this file?" %}');" title="{% trans 'Delete File' %}">{% trans 'Delete File' %}</a></li>
                    {% else %}
                        {% if file.is_empty %}
                            <li><a href="{% url fb_delete %}{% query_string %}&amp;filename={{ file.filename }}&amp;filetype={{ file.filetype }}" onclick="return confirm('{% trans "Are you sure you want to delete this Folder?" %}');" title="{% trans 'Delete Folder' %}">{% trans 'Delete Folder' %}</a></li>
                        {% endif %}
                    {% endifnotequal %}
                </ul>
            </div>
        </td>
        
        <!-- DEBUG -->
        {% if settings_var.DEBUG %}
        <td>
            <strong>Filename</strong> {{ file.filename }}<br />
            <strong>Filetype</strong> {{ file.filetype }}<br />
            <strong>Filesize</strong> {{ file.filesize }}<br />
            <strong>Extension</strong> {{ file.extension }}<br />
            <strong>Date</strong> {{ file.date }}<br />
            <strong>Datetime Object</strong> {{ file.datetime }}<br /><br />
            <strong>Relative Path</strong> {{ file.path_relative }}<br />
            <strong>Full Path</strong> {{ file.path_full }}<br />
            <strong>Relative URL</strong> {{ file.url_relative }}<br />
            <strong>Full URL</strong> {{ file.url_full }}<br /><br />
            <strong>URL for FileBrowseField</strong> {{ file.url_save }}<br />
            <strong>Thumbnail URL</strong> {{ file.url_thumbnail }}
            {% if file.filetype == "Image" %}
                <br /><br />
                <strong>Dimensions</strong> {{ file.dimensions }}<br />
                <strong>Width</strong> {{ file.width }}<br />
                <strong>Height</strong> {{ file.height }}<br />
                <strong>Orientation</strong> {{ file.orientation }}
            {% endif %}
            {% if file.filetype == "Folder" %}
                <br /><br />
                <strong>Is Empty</strong> {{ file.is_empty }}
            {% endif %}
        </td>
        {% endif %}
        
    </tr>
{% endfor %}

 